/**
 * jims
 */
package com.jims.master.modules.doctor.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jims.master.common.persistence.DataEntity;
import com.jims.master.modules.reg.entity.ClinicForRegist;
import com.jims.master.modules.sys.entity.User;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.beans.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 病人就诊信息Entity
 * @author 赵宁
 * @version 2017-02-28
 */
public class ClinicMaster extends DataEntity<ClinicMaster> {
	
	private static final long serialVersionUID = 1L;
	private String orgId;		// 组织机构Id
	private String registType;//挂号类型 0:当日挂号 1：预约挂号
	private String patientId;		// 病人信息Id
	private Date visitDate;		// 就诊日期
	private String visitNo;		// 就诊序号
	private String clinicNo;		// 门诊号
	private String registId;		// 号表ID
	private String name;		// 姓名
	private String sex;		// 性别
	private String age;		// 年龄
	private String identity;		// 身份
	private String chargeType;		// 费别
	private String insuranceTypr;		// 医保类别
	private String insuranceNo;		// 医疗保险号
	private String unitInContract;		// 合同单位
	private String deptId;		// 就诊科室
    private String deptName;		// 就诊科室名称
	private String doctorId;		// 医生Id
	private String clinicType;		// 挂号状态 0:未就诊 1：已就诊 2：退号
	private Double clinicChage;		// 实收费用
	private Date registDate;		// 退号日期
	private String registOperator;		// 退号操作员
	private Date acctDateTime;		// 结账时间
	private String acctNo;		// 结账号
	private String firstVisitIndicator;		// 初诊标志
	private int registCount;  //挂号总数
	private int backCount;   //退号总数
	private double totalCost;   //计价总额
	private double baclTotalCost;  //退号总额
	private double totalReceipts; //实收总额
	private double backChage; //退号金额
	private double receiptsChage; //实收小计
	private String checkStartTime; //截止开始时间
	private String checkEndTime; //截止结束时间
    private String charge;//
	private String isPhy;// 是否体检
    private String clinicId;
    private String cardFlag;
    private String cardNo;

    private Integer referralNum; //转诊次数
    public String getClinicId() {
        return clinicId;
    }

    public void setClinicId(String clinicId) {
        this.clinicId = clinicId;
    }

    private List<String> clinicNos=new ArrayList<String>();
	private ClinicForRegist clinicForRegist;//号表
	private String type;//支付类型
    //查询扩展字段
    private String likeText;// 输入框模糊查询条件
    private String powerDeptIds;  //判断是否权限科室

    private  PatMasterIndex patMasterIndex; //病人基本信息
	private User user;

    private String clinicAttr;

    private String doctorOper;

    public String getDoctorOper() {
        return doctorOper;
    }

    public void setDoctorOper(String doctorOper) {
        this.doctorOper = doctorOper;
    }

    /**
     * 是否仅限一卡通
     * @return
     */
    @Transient
    public boolean getOnlyCard() {
        if(this.clinicAttr==null){
            return false;
        }else{
            if("11".equals(this.clinicAttr)){
                return false;
            }else{
                return true;
            }
        }
    }



    /**
     * 是否仅限本科室
     * @return
     */
    public boolean getOnlyLocal() {
        if("0".equals(getDoctorOper())){
            return false;
        }else if(getOnlyCard()){
            return false;
        }else{
            return true;
        }
     }



    public String getClinicAttr() {
        return clinicAttr;
    }

    public void setClinicAttr(String clinicAttr) {
        this.clinicAttr = clinicAttr;
    }

    public String getCharge() {
        return charge;
    }

    public void setCharge(String charge) {
        this.charge = charge;
    }

    public ClinicMaster() {
		super();
        this.referralNum=0;
	}

	public ClinicMaster(String id){
		super(id);
	}

    public PatMasterIndex getPatMasterIndex() {
        return patMasterIndex;
    }

    public void setPatMasterIndex(PatMasterIndex patMasterIndex) {
        this.patMasterIndex = patMasterIndex;
    }

    @Length(min=1, max=64, message="组织机构Id长度必须介于 1 和 64 之间")
	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}
	
	@Length(min=1, max=64, message="病人信息Id长度必须介于 1 和 64 之间")
	public String getPatientId() {
		return patientId;
	}

	public void setPatientId(String patientId) {
		this.patientId = patientId;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="就诊日期不能为空")
	public Date getVisitDate() {
		return visitDate;
	}

	public void setVisitDate(Date visitDate) {
		this.visitDate = visitDate;
	}
	
	@Length(min=1, max=11, message="就诊序号长度必须介于 1 和 11 之间")
	public String getVisitNo() {
		return visitNo;
	}

	public void setVisitNo(String visitNo) {
		this.visitNo = visitNo;
	}
	
	@Length(min=1, max=100, message="门诊号长度必须介于 1 和 100 之间")
	public String getClinicNo() {
		return clinicNo;
	}

	public void setClinicNo(String clinicNo) {
		this.clinicNo = clinicNo;
	}
	
	@Length(min=1, max=64, message="号表ID长度必须介于 1 和 64 之间")
	public String getRegistId() {
		return registId;
	}

	public void setRegistId(String registId) {
		this.registId = registId;
	}
	
	@Length(min=1, max=200, message="姓名长度必须介于 1 和 200 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=0, max=1, message="性别长度必须介于 0 和 1 之间")
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}
	
	@Length(min=0, max=11, message="年龄长度必须介于 0 和 11 之间")
	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}
	
	@Length(min=0, max=2, message="身份长度必须介于 0 和 2 之间")
	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}
	
	@Length(min=0, max=2, message="费别长度必须介于 0 和 2 之间")
	public String getChargeType() {
		return chargeType;
	}

	public void setChargeType(String chargeType) {
		this.chargeType = chargeType;
	}
	
	@Length(min=0, max=2, message="医保类别长度必须介于 0 和 2 之间")
	public String getInsuranceTypr() {
		return insuranceTypr;
	}

	public void setInsuranceTypr(String insuranceTypr) {
		this.insuranceTypr = insuranceTypr;
	}
	
	@Length(min=0, max=100, message="医疗保险号长度必须介于 0 和 100 之间")
	public String getInsuranceNo() {
		return insuranceNo;
	}

	public void setInsuranceNo(String insuranceNo) {
		this.insuranceNo = insuranceNo;
	}
	
	@Length(min=0, max=200, message="合同单位长度必须介于 0 和 200 之间")
	public String getUnitInContract() {
		return unitInContract;
	}

	public void setUnitInContract(String unitInContract) {
		this.unitInContract = unitInContract;
	}
	
	@Length(min=0, max=64, message="就诊科室长度必须介于 0 和 64 之间")
	public String getDeptId() {
		return deptId;
	}

	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}
	
	@Length(min=0, max=64, message="医生Id长度必须介于 0 和 64 之间")
	public String getDoctorId() {
		return doctorId;
	}

	public void setDoctorId(String doctorId) {
		this.doctorId = doctorId;
	}
	
	@Length(min=0, max=1, message="挂号状态长度必须介于 0 和 1 之间")
	public String getClinicType() {
		return clinicType;
	}

	public void setClinicType(String clinicType) {
		this.clinicType = clinicType;
	}

	public Double getClinicChage() {
		return clinicChage;
	}

	public void setClinicChage(Double clinicChage) {
		this.clinicChage = clinicChage;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getRegistDate() {
		return registDate;
	}

	public void setRegistDate(Date registDate) {
		this.registDate = registDate;
	}
	
	@Length(min=0, max=64, message="退号操作员长度必须介于 0 和 64 之间")
	public String getRegistOperator() {
		return registOperator;
	}

	public void setRegistOperator(String registOperator) {
		this.registOperator = registOperator;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getAcctDateTime() {
		return acctDateTime;
	}

	public void setAcctDateTime(Date acctDateTime) {
		this.acctDateTime = acctDateTime;
	}
	
	@Length(min=0, max=100, message="结账号长度必须介于 0 和 100 之间")
	public String getAcctNo() {
		return acctNo;
	}

	public int getRegistCount() {
		return registCount;
	}

	public void setRegistCount(int registCount) {
		this.registCount = registCount;
	}

	public int getBackCount() {
		return backCount;
	}

	public void setBackCount(int backCount) {
		this.backCount = backCount;
	}

	public double getTotalCost() {
		return totalCost;
	}

	public void setTotalCost(double totalCost) {
		this.totalCost = totalCost;
	}

	public double getBaclTotalCost() {
		return baclTotalCost;
	}

	public void setBaclTotalCost(double baclTotalCost) {
		this.baclTotalCost = baclTotalCost;
	}

	public double getTotalReceipts() {
		return totalReceipts;
	}

	public void setTotalReceipts(double totalReceipts) {
		this.totalReceipts = totalReceipts;
	}

	public double getBackChage() {
		return backChage;
	}

	public void setBackChage(double backChage) {
		this.backChage = backChage;
	}

	public double getReceiptsChage() {
		return receiptsChage;
	}

	public void setReceiptsChage(double receiptsChage) {
		this.receiptsChage = receiptsChage;
	}

	public void setAcctNo(String acctNo) {
		this.acctNo = acctNo;
	}

	public String getFirstVisitIndicator() {
		return firstVisitIndicator;
	}

	public void setFirstVisitIndicator(String firstVisitIndicator) {
		this.firstVisitIndicator = firstVisitIndicator;
	}

	public ClinicForRegist getClinicForRegist() {
		return clinicForRegist;
	}

	public void setClinicForRegist(ClinicForRegist clinicForRegist) {
		this.clinicForRegist = clinicForRegist;
	}

	public String getCheckStartTime() { return checkStartTime; }

	public void setCheckStartTime(String checkStartTime) { this.checkStartTime = checkStartTime; }

	public String getCheckEndTime() { return checkEndTime; }

	public void setCheckEndTime(String checkEndTime) { this.checkEndTime = checkEndTime; }

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

    public String getLikeText() {
        return likeText;
    }

    public void setLikeText(String likeText) {
        this.likeText = likeText;
    }

    public String getPowerDeptIds() {
        return powerDeptIds;
    }

    public void setPowerDeptIds(String powerDeptIds) {
        this.powerDeptIds = powerDeptIds;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

	public String getRegistType() {
		return registType;
	}

	public void setRegistType(String registType) {
		this.registType = registType;
	}

	public String getIsPhy() {
		return isPhy;
	}

	public void setIsPhy(String isPhy) {
		this.isPhy = isPhy;
	}

    public List<String> getClinicNos() {
        if(this.clinicNo!=null&&!"".equals(this.clinicNo)){
           String[] clinicArr=this.clinicNo.split(",");
           for(String clinicNo:clinicArr){
               clinicNos.add(clinicNo);
           }
        }
        return clinicNos;
    }

    public void setClinicNos(List<String> clinicNos) {
        this.clinicNos = clinicNos;
    }

    public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

    public String getCardFlag() {
        return cardFlag;
    }

    public void setCardFlag(String cardFlag) {
        this.cardFlag = cardFlag;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public Integer getReferralNum() {
        return referralNum;
    }

    public void setReferralNum(Integer referralNum) {
        this.referralNum = referralNum;
    }
}